<!DOCTYPE html>
<html class="client-nojs vector-feature-night-mode-disabled vector-feature-language-in-header-enabled vector-feature-language-in-main-page-header-disabled vector-feature-page-tools-pinned-disabled vector-feature-toc-pinned-clientpref-1 vector-feature-main-menu-pinned-disabled vector-feature-limited-width-clientpref-1 vector-feature-limited-width-content-enabled vector-feature-custom-font-size-clientpref-1 vector-feature-appearance-pinned-clientpref-1 vector-sticky-header-enabled" lang="en" dir="ltr"><head>
<meta charset="UTF-8">
<title>FP (programming language)</title>
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<link rel="canonical" href="https://en.wikipedia.org/wiki/FP_(programming_language)"> <link href="./mw/ext.cite.styles.css" rel="stylesheet" type="text/css">
<link href="./mw/skins.vector.icons.css" rel="stylesheet" type="text/css">
<link href="./mw/skins.vector.search.codex.styles.css" rel="stylesheet" type="text/css">
<link href="./mw/skins.vector.styles.css" rel="stylesheet" type="text/css">
<link href="./mw/user.styles.css" rel="stylesheet" type="text/css">
<meta name="ResourceLoaderDynamicStyles" content="">
<link rel="stylesheet" type="text/css" href="./mw/site.styles.css">
<link rel="stylesheet" type="text/css" href="./mw/noscript.css">
<link rel="stylesheet" type="text/css" href="./footer.css">
<link rel="stylesheet" type="text/css" href="./vector-2022.css">
</head>
<body class="skin--responsive skin-vector skin-vector-search-vue mediawiki ltr sitedir-ltr mw-hide-empty-elt ns-0 ns-subject page-FP_programming_language rootpage-FP_programming_language skin-vector-2022 action-view">
<div class="mw-page-container">
<div class="mw-page-container-inner">
<div class="mw-content-container">
<main id="content" class="mw-body">
<header class="mw-body-header vector-page-titlebar">
<h1 id="firstHeading" class="firstHeading mw-first-heading">
<span id="openzim-page-title" class="mw-page-title-main"><span class="mw-page-title-main">FP (programming language)</span></span>
</h1>
</header>
<a id="top"></a>
<div id="bodyContent" class="vector-body ve-init-mw-desktopArticleTarget-targetContainer" aria-labelledby="firstHeading" data-mw-ve-target-container="">
<div id="mw-content-text" class="mw-body-content mw-content-ltr" lang="en" dir="ltr"><div class="mw-content-ltr mw-parser-output" lang="en" dir="ltr">
<style data-mw-deduplicate="TemplateStyles:r1295905060">
/* start https://en.wikipedia.org/ */
.mw-parser-output .infobox-subbox{padding:0;border:none;margin:-3px;width:auto;min-width:100%;font-size:100%;clear:none;float:none;background-color:transparent}.mw-parser-output .infobox-3cols-child{margin:auto}.mw-parser-output .infobox .navbar{font-size:100%}@media screen{html.skin-theme-clientpref-night .mw-parser-output .infobox-full-data:not(.notheme)>div:not(.notheme)[style]{background:#1f1f23!important;color:#f8f9fa}}@media screen and (prefers-color-scheme:dark){html.skin-theme-clientpref-os .mw-parser-output .infobox-full-data:not(.notheme)>div:not(.notheme)[style]{background:#1f1f23!important;color:#f8f9fa}}@media(min-width:640px){body.skin--responsive .mw-parser-output .infobox-table{display:table!important}body.skin--responsive .mw-parser-output .infobox-table>caption{display:table-caption!important}body.skin--responsive .mw-parser-output .infobox-table>tbody{display:table-row-group}body.skin--responsive .mw-parser-output .infobox-table th,body.skin--responsive .mw-parser-output .infobox-table td{padding-left:inherit;padding-right:inherit}}
/* end https://en.wikipedia.org/ */
</style><table class="infobox vevent"><tbody><tr><th colspan="2" class="infobox-above" style="background-color:#e0e0e0;">FP</th></tr><tr><th scope="row" class="infobox-label"><a href="Programming_paradigm" title="Programming paradigm">Paradigm</a></th><td class="infobox-data"><a href="Function-level_programming" title="Function-level programming">Function-level</a></td></tr><tr><th scope="row" class="infobox-label"><a href="Software_design" title="Software design">Designed by</a></th><td class="infobox-data"><a href="John_Backus" title="John Backus">John Backus</a></td></tr><tr><th scope="row" class="infobox-label">First appeared</th><td class="infobox-data">1977</td></tr><tr><th colspan="2" class="infobox-header" style="background-color: #EEEEEE;"><a href="Programming_language#Dialects,_flavors_and_implementations" title="Programming language">Dialects</a></th></tr><tr><td colspan="2" class="infobox-full-data">FP84</td></tr><tr><th colspan="2" class="infobox-header" style="background-color: #EEEEEE;">Influenced by</th></tr><tr><td colspan="2" class="infobox-full-data"><a href="APL_(programming_language)" title="APL (programming language)">APL</a><sup id="cite_ref-Hudak_1989_1-0" class="reference"><a href="#cite_note-Hudak_1989-1"><span class="cite-bracket">[</span>1<span class="cite-bracket">]</span></a></sup></td></tr><tr><th colspan="2" class="infobox-header" style="background-color: #EEEEEE;">Influenced</th></tr><tr><td colspan="2" class="infobox-full-data"><a href="FL_(programming_language)" title="FL (programming language)">FL</a>, <a href="Haskell_(programming_language)" class="mw-redirect" title="Haskell (programming language)">Haskell</a>, <a href="Joy_(programming_language)" title="Joy (programming language)">Joy</a></td></tr></tbody></table>
<p><b>FP</b> (short for <i>functional programming</i>)<sup id="cite_ref-Backus_1977_2-0" class="reference"><a href="#cite_note-Backus_1977-2"><span class="cite-bracket">[</span>2<span class="cite-bracket">]</span></a></sup> is a <a href="Programming_language" title="Programming language">programming language</a> created by <a href="John_Backus" title="John Backus">John Backus</a> to support the <a href="Function-level_programming" title="Function-level programming">function-level programming</a><sup id="cite_ref-Backus_1977_2-1" class="reference"><a href="#cite_note-Backus_1977-2"><span class="cite-bracket">[</span>2<span class="cite-bracket">]</span></a></sup> paradigm. It allows building programs from a set of generally useful primitives and avoiding named variables (a style also called <a href="Tacit_programming" title="Tacit programming">tacit programming</a> or "point free"). It was heavily influenced by <a href="APL_(programming_language)" title="APL (programming language)">APL</a> developed by <a href="Kenneth_E._Iverson" title="Kenneth E. Iverson">Kenneth E. Iverson</a> in the early 1960s.<sup id="cite_ref-acm_3-0" class="reference"><a href="#cite_note-acm-3"><span class="cite-bracket">[</span>3<span class="cite-bracket">]</span></a></sup>
</p><p>The FP language was introduced in Backus's 1977 <a href="Turing_Award" title="Turing Award">Turing Award</a> paper, "Can Programming Be Liberated from the von Neumann Style?", subtitled "a functional style and its algebra of programs." The paper sparked interest in <a href="Functional_programming" title="Functional programming">functional programming</a> research,<sup id="cite_ref-4" class="reference"><a href="#cite_note-4"><span class="cite-bracket">[</span>4<span class="cite-bracket">]</span></a></sup> eventually leading to modern functional languages, which are largely founded on the <a href="Lambda_calculus" title="Lambda calculus">lambda calculus</a> paradigm, and not the function-level paradigm Backus had hoped. In his Turing award paper, Backus described how the FP style is different:
</p>
<style data-mw-deduplicate="TemplateStyles:r1244412712">
/* start https://en.wikipedia.org/ */
.mw-parser-output .templatequote{overflow:hidden;margin:1em 0;padding:0 32px}.mw-parser-output .templatequotecite{line-height:1.5em;text-align:left;margin-top:0}@media(min-width:500px){.mw-parser-output .templatequotecite{padding-left:1.6em}}
/* end https://en.wikipedia.org/ */
</style><blockquote class="templatequote"><p>An FP system is based on the use of a fixed set of combining forms called functional forms. These, plus simple definitions, are the only means of building new functions from existing ones; they use no variables or substitutions rules, and they become the operations of an associated algebra of programs. All the functions of an FP system are of one type: they map objects onto objects and always take a single argument.<sup id="cite_ref-Backus_1977_2-2" class="reference"><a href="#cite_note-Backus_1977-2"><span class="cite-bracket">[</span>2<span class="cite-bracket">]</span></a></sup></p></blockquote>
<p>FP itself never found much use outside of academia.<sup id="cite_ref-p21_5-0" class="reference"><a href="#cite_note-p21-5"><span class="cite-bracket">[</span>5<span class="cite-bracket">]</span></a></sup> In the 1980s Backus created a successor language, <a href="FL_(programming_language)" title="FL (programming language)">FL</a> as an internal project at <a href="IBM_Research" title="IBM Research">IBM Research</a>.
</p>
<meta property="mw:PageProp/toc">
<div class="mw-heading mw-heading2"><h2 id="Overview">Overview</h2></div>
<p>The <b>values</b> that FP programs map into one another comprise a <a href="Set_(abstract_data_type)" title="Set (abstract data type)">set</a> which is <a href="Closure_(mathematics)" title="Closure (mathematics)">closed</a> under <b>sequence formation</b>:
</p>
<pre>if <b>x</b><sub>1</sub>,...,<b>x</b><sub>n</sub> are <b>values</b>, then the <b>sequence</b> 〈<b>x</b><sub>1</sub>,...,<b>x</b><sub>n</sub>〉 is also a <b>value</b>
</pre>
<p>These values can be built from any set of atoms: booleans, integers, reals, characters, etc.:
</p>
<pre><b>boolean</b> : {<b>T</b>, <b>F</b>}
<b>integer</b> : {0,1,2,...,∞}
<b>character</b> : {'a','b','c',...}
<b>symbol</b> : {<b>x</b>,<b>y</b>,...}
</pre>
<p><b>⊥</b> is the <b>undefined</b> value, or <b>bottom</b>. Sequences are <i>bottom-preserving</i>:
</p>
<pre>〈<b>x</b><sub>1</sub>,...,<b>⊥</b>,...,<b>x</b><sub>n</sub>〉 = <b>⊥</b>
</pre>
<p>FP programs are <i>functions</i> <b>f</b> that each map a single <i>value</i> <b>x</b> into another:
</p>
<pre><b>f</b>:<b>x</b> represents the <b>value</b> that results from applying the <b>function</b> <b>f</b>
to the <b>value</b> <b>x</b>
</pre>
<p>Functions are either primitive (i.e., provided with the FP environment) or are built from the primitives by <b>program-forming operations</b> (also called <b>functionals</b>).
</p><p>An example of primitive function is <b>constant</b>, which transforms a value <b>x</b> into the constant-valued function <b>x̄</b>. Functions are <a href="Strict_function" title="Strict function">strict</a>:
</p>
<pre><b>f</b>:<b>⊥</b> = <b>⊥</b>
</pre>
<p>Another example of a primitive function is the <b>selector</b> function family, denoted by <b>1</b>,<b>2</b>,... where:
</p>
<pre><i><b>i</b></i>:〈<b>x</b><sub>1</sub>,...,<b>x</b><sub>n</sub>〉 = <b>x</b><sub>i</sub> if 1 ≤ <i><b>i</b></i> ≤ n
= ⊥ otherwise
</pre>
<div class="mw-heading mw-heading2"><h2 id="Functionals">Functionals</h2></div>
<p>In contrast to primitive functions, functionals operate on other functions. For example, some functions have a <i>unit</i> value, such as 0 for <i>addition</i> and 1 for <i>multiplication</i>. The functional <b>unit</b> produces such a <b>value</b> when applied to a <b>function f</b> that has one:
</p>
<pre><b>unit +</b> = 0
<b>unit ×</b> = 1
<b>unit foo</b> = ⊥
</pre>
<p>These are the core functionals of FP:
</p>
<pre><b>composition</b> <b>f</b>∘<b>g</b> where <b>f</b>∘<b>g</b>:<b>x</b> = <b>f</b>:(<b>g</b>:<b>x</b>)
</pre>
<pre><b>construction</b> [<b>f</b><sub>1</sub>,...,<b>f</b><sub>n</sub>] where [<b>f</b><sub>1</sub>,...,<b>f</b><sub>n</sub>]:<b>x</b> = 〈<b>f</b><sub>1</sub>:<b>x</b>,...,<b>f</b><sub>n</sub>:<b>x</b>〉
</pre>
<pre><b>condition</b> (<b>h</b> ⇒ <b>f</b>;<b>g</b>) where (<b>h</b> ⇒ <b>f</b>;<b>g</b>):<b>x</b> = <b>f</b>:<b>x</b> if <b>h</b>:<b>x</b> = <b>T</b>
= <b>g</b>:<b>x</b> if <b>h</b>:<b>x</b> = <b>F</b>
= <b>⊥</b> otherwise
</pre>
<pre><b>apply-to-all</b> <i>α</i><b>f</b> where <i>α</i><b>f</b>:〈<b>x</b><sub>1</sub>,...,<b>x</b><sub>n</sub>〉 = 〈<b>f</b>:<b>x</b><sub>1</sub>,...,<b>f</b>:<b>x</b><sub>n</sub>〉
</pre>
<pre><b>insert-right</b> /<b>f</b> where /<b>f</b>:〈<b>x</b>〉 = <b>x</b>
and /<b>f</b>:〈<b>x</b><sub>1</sub>,<b>x</b><sub>2</sub>,...,<b>x</b><sub>n</sub>〉 = <b>f</b>:〈<b>x</b><sub>1</sub>,/<b>f</b>:〈<b>x</b><sub>2</sub>,...,<b>x</b><sub>n</sub>〉〉
and /<b>f</b>:〈 〉 = <b>unit f</b>
</pre>
<pre><b>insert-left</b> \<b>f</b> where \<b>f</b>:〈<b>x</b>〉 = <b>x</b>
and \<b>f</b>:〈<b>x</b><sub>1</sub>,<b>x</b><sub>2</sub>,...,<b>x</b><sub>n</sub>〉 = <b>f</b>:〈\<b>f</b>:〈<b>x</b><sub>1</sub>,...,<b>x</b><sub>n-1</sub>〉,<b>x</b><sub>n</sub>〉
and \<b>f</b>:〈 〉 = <b>unit f</b>
</pre>
<div class="mw-heading mw-heading2"><h2 id="Equational_functions">Equational functions</h2></div>
<p>In addition to being constructed from primitives by functionals, a function may be defined recursively by an equation, the simplest kind being:
</p>
<pre><b>f</b> ≡ <i>E</i><b>f</b>
</pre>
<p>where <i>E</i><b>f</b> is an <a href="Expression_(computer_science)" title="Expression (computer science)">expression</a> built from primitives, other defined functions, and the function symbol <b>f</b> itself, using functionals.
</p>
<div class="mw-heading mw-heading2"><h2 id="FP84">FP84</h2></div>
<p><b>FP84</b> is an extension of FP to include <a href="Infinite_sequence" class="mw-redirect" title="Infinite sequence">infinite sequences</a>, programmer-defined <a href="Combining_form" class="mw-redirect" title="Combining form">combining forms</a> (analogous to those that Backus himself added to <a href="FL_programming_language" class="mw-redirect" title="FL programming language">FL</a>, his successor to FP), and <a href="Lazy_evaluation" title="Lazy evaluation">lazy evaluation</a>. Unlike FFP, another one of Backus' own variations on FP, FP84 makes a clear distinction between objects and functions: i.e., the latter are no longer represented by sequences of the former. FP84's extensions are accomplished by removing the FP restriction that sequence construction be applied only to <i>non</i>-⊥ objects: in FP84 the entire universe of expressions (including those whose meaning is ⊥) is <a href="Closed_under" class="mw-redirect" title="Closed under">closed under</a> sequence construction.
</p><p>FP84's semantics are embodied in an underlying algebra of programs, a set of <a href="Function-level_programming" title="Function-level programming">function-level</a> equalities that may be used to manipulate and reason about programs.
</p>
<div class="mw-heading mw-heading2"><h2 id="References">References</h2></div>
<style data-mw-deduplicate="TemplateStyles:r1239543626">
/* start https://en.wikipedia.org/ */
.mw-parser-output .reflist{margin-bottom:0.5em;list-style-type:decimal}@media screen{.mw-parser-output .reflist{font-size:90%}}.mw-parser-output .reflist .references{font-size:100%;margin-bottom:0;list-style-type:inherit}.mw-parser-output .reflist-columns-2{column-width:30em}.mw-parser-output .reflist-columns-3{column-width:25em}.mw-parser-output .reflist-columns{margin-top:0.3em}.mw-parser-output .reflist-columns ol{margin-top:0}.mw-parser-output .reflist-columns li{page-break-inside:avoid;break-inside:avoid-column}.mw-parser-output .reflist-upper-alpha{list-style-type:upper-alpha}.mw-parser-output .reflist-upper-roman{list-style-type:upper-roman}.mw-parser-output .reflist-lower-alpha{list-style-type:lower-alpha}.mw-parser-output .reflist-lower-greek{list-style-type:lower-greek}.mw-parser-output .reflist-lower-roman{list-style-type:lower-roman}
/* end https://en.wikipedia.org/ */
</style><div class="reflist">
<div class="mw-references-wrap"><ol class="references">
<li id="cite_note-Hudak_1989-1"><span class="mw-cite-backlink"><b><a href="#cite_ref-Hudak_1989_1-0">^</a></b></span> <span class="reference-text"><a rel="nofollow" class="external text" href="https://dl.acm.org/doi/10.1145/72551.72554">The Conception, Evolution, and Application of Functional Programming Languages</a> <a rel="nofollow" class="external text" href="https://web.archive.org/web/20160311204021/http://haskell.cs.yale.edu/wp-content/uploads/2011/01/cs.pdf">Archived</a> 2016-03-11 at the <a href="Wayback_Machine" title="Wayback Machine">Wayback Machine</a> Paul Hudak, 1989</span>
</li>
<li id="cite_note-Backus_1977-2"><span class="mw-cite-backlink">^ <a href="#cite_ref-Backus_1977_2-0"><sup><i><b>a</b></i></sup></a> <a href="#cite_ref-Backus_1977_2-1"><sup><i><b>b</b></i></sup></a> <a href="#cite_ref-Backus_1977_2-2"><sup><i><b>c</b></i></sup></a></span> <span class="reference-text"><style data-mw-deduplicate="TemplateStyles:r1238218222">
/* start https://en.wikipedia.org/ */
.mw-parser-output cite.citation{font-style:inherit;word-wrap:break-word}.mw-parser-output .citation q{quotes:"\"""\"""'""'"}.mw-parser-output .citation:target{background-color:rgba(0,127,255,0.133)}.mw-parser-output .id-lock-free.id-lock-free a{background:url("./mw/Lock-green.svg")right 0.1em center/9px no-repeat}.mw-parser-output .id-lock-limited.id-lock-limited a,.mw-parser-output .id-lock-registration.id-lock-registration a{background:url("./mw/Lock-gray-alt-2.svg")right 0.1em center/9px no-repeat}.mw-parser-output .id-lock-subscription.id-lock-subscription a{background:url("./mw/Lock-red-alt-2.svg")right 0.1em center/9px no-repeat}.mw-parser-output .cs1-ws-icon a{background:url("./mw/Wikisource-logo.svg")right 0.1em center/12px no-repeat}body:not(.skin-timeless):not(.skin-minerva) .mw-parser-output .id-lock-free a,body:not(.skin-timeless):not(.skin-minerva) .mw-parser-output .id-lock-limited a,body:not(.skin-timeless):not(.skin-minerva) .mw-parser-output .id-lock-registration a,body:not(.skin-timeless):not(.skin-minerva) .mw-parser-output .id-lock-subscription a,body:not(.skin-timeless):not(.skin-minerva) .mw-parser-output .cs1-ws-icon a{background-size:contain;padding:0 1em 0 0}.mw-parser-output .cs1-code{color:inherit;background:inherit;border:none;padding:inherit}.mw-parser-output .cs1-hidden-error{display:none;color:var(--color-error,#d33)}.mw-parser-output .cs1-visible-error{color:var(--color-error,#d33)}.mw-parser-output .cs1-maint{display:none;color:#085;margin-left:0.3em}.mw-parser-output .cs1-kern-left{padding-left:0.2em}.mw-parser-output .cs1-kern-right{padding-right:0.2em}.mw-parser-output .citation .mw-selflink{font-weight:inherit}@media screen{.mw-parser-output .cs1-format{font-size:95%}html.skin-theme-clientpref-night .mw-parser-output .cs1-maint{color:#18911f}}@media screen and (prefers-color-scheme:dark){html.skin-theme-clientpref-os .mw-parser-output .cs1-maint{color:#18911f}}
/* end https://en.wikipedia.org/ */
</style><cite id="CITEREFBackus1978" class="citation journal cs1">Backus, J. (1978). <a rel="nofollow" class="external text" href="https://doi.org/10.1145%2F359576.359579">"Can programming be liberated from the von Neumann style?: A functional style and its algebra of programs"</a>. <i>Communications of the ACM</i>. <b>21</b> (8): 613. <a href="Doi_(identifier)" class="mw-redirect" title="Doi (identifier)">doi</a>:<span class="id-lock-free" title="Freely accessible"><a rel="nofollow" class="external text" href="https://doi.org/10.1145%2F359576.359579">10.1145/359576.359579</a></span>.</cite></span>
</li>
<li id="cite_note-acm-3"><span class="mw-cite-backlink"><b><a href="#cite_ref-acm_3-0">^</a></b></span> <span class="reference-text"><cite class="citation web cs1"><a rel="nofollow" class="external text" href="http://signallake.com/innovation/JBackus032007.pdf">"Association for Computing Machinery A. M. Turing Award"</a> <span class="cs1-format">(PDF)</span>.</cite></span>
</li>
<li id="cite_note-4"><span class="mw-cite-backlink"><b><a href="#cite_ref-4">^</a></b></span> <span class="reference-text"><cite id="CITEREFYang2017" class="citation web cs1">Yang, Jean (2017). <a rel="nofollow" class="external text" href="https://www.cs.cmu.edu/~popl-interviews/peytonjones.html">"Interview with Simon Peyton-Jones"</a>. <i>People of Programming Languages</i>.</cite></span>
</li>
<li id="cite_note-p21-5"><span class="mw-cite-backlink"><b><a href="#cite_ref-p21_5-0">^</a></b></span> <span class="reference-text"><cite id="CITEREFHague2007" class="citation web cs1">Hague, James (December 28, 2007). <a rel="nofollow" class="external text" href="http://prog21.dadgum.com/14.html">"Functional Programming Archaeology"</a>. <i>Programming in the Twenty-First Century</i>.</cite></span>
</li>
</ol></div></div>
<ul><li><i>Sacrificing simplicity for convenience: Where do you draw the line?</i>, John H. Williams and Edward L. Wimmers, IBM Almaden Research Center, Proceedings of the Fifteenth Annual ACM SIGACT-SIGPLAN Symposium on Principles of Programming Languages, San Diego, CA, January 1988.</li></ul>
<div class="mw-heading mw-heading2"><h2 id="External_links">External links</h2></div>
<ul><li><a rel="nofollow" class="external text" href="https://pointfree-interpreter.github.io/">FP-Interpreter</a> written in Delphi/Lazarus</li>
<li><a rel="nofollow" class="external text" href="http://dirkgerrits.com/publications/john-backus.pdf#section.9">Dirk Gerrits: Turing Award lecture (1977-1978) ff</a>, in John W. Backus (Publications)</li>
<li>FP84 vs FL: <a rel="nofollow" class="external text" href="https://dl.acm.org/doi/pdf/10.1145/73560.73575">Sacrificing simplicity for convenience: Where do you draw the line?</a> J.H. William and E.L. Wimmers, 1988 (Pages 169–179)</li></ul></div><!--htdig_noindex--><div><div class="zim-footer">
This article is issued from <a class="external text" title="Last edited on 2024-04-08" href="https://en.wikipedia.org/wiki/?title=FP_(programming_language)&oldid=1217859699">Wikipedia</a>. The text is available under <a class="external text" href="https://creativecommons.org/licenses/by-sa/4.0/deed.en">Creative Commons Attribution-Share Alike 4.0</a> unless otherwise noted. Additional terms may apply for the media files.
</div>
</div><!--/htdig_noindex--></div>
</div>
</main>
</div>
</div>
</div>
</body></html>